package modelo;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.EOFException;
import java.io.File;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Scanner;

import controlador.Jugador;
import android.app.Activity;
import android.content.Context;

public class Texto_DAO {

	public void grabar(Activity ma, Jugador j) {

		try {
			BufferedWriter oFile = new BufferedWriter( new OutputStreamWriter(ma.openFileOutput(
					"puntuaciones.txt", Context.MODE_APPEND)));

			oFile.write(j.getNombre() + "         " + j.getVictorias());
			oFile.newLine();
			oFile.close();
		} catch (Exception ex) {
			ex.getMessage();
		}
	}

	public ArrayList<String> mostrar(Activity ma) {
		ArrayList<String> datos = new 	ArrayList<String>();
		try {
			BufferedReader fin = new BufferedReader(new InputStreamReader(
					ma.openFileInput("puntuaciones.txt")));
			String dato = null;
			while ((dato = fin.readLine()) != null) {

					datos.add(dato);

			}

			fin.close();
			
		} catch (Exception ex) {
			ex.getMessage();
		}

		return datos;
	}

}

